<%-- 自定义实体添加页面 --%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="/views/common/taglibs.jsp" %>

<!DOCTYPE>
<html>
<head>
    <!-- 引入通用js、css文件(xiaogq) -->
    <meta name="decorator" content="bootstrap"/>
    <link rel="stylesheet" type="text/css" href="${ctx}/css/system/custom/entity/entity_add.css"/>
    <link rel="stylesheet" type="text/css" href="${ctx}/css/common/operation/sys_operation.css"/>
</head>
<body>
<!-- 加载列表操作 -->
<div class="button_list">
    <a href="javascript:;" onclick="saveEditRole();">
        <span class="span_button">
            <span><img src="${ctx}/image/common/operation/oper_SAVE.png"></span>
            <span name="buTitle">保存</span>
        </span>
    </a>
    <a href="javascript:;" onclick="javascript:parent.closeTab();">
        <span class="span_button">
            <span><img src="${ctx}/image/common/operation/oper_CANCEL.png"></span>
            <span name="buTitle">取消</span>
        </span>
    </a>
</div>

<div class="content row">
    <h3>基础信息</h3>
    <hr>
    <form role="form" class="entityForm" id="entity_form" method="post" action="${ctx}/${saveUrl}" enctype="multipart/form-data">
        <input type="hidden" name="entityId" value="${entity.tableCode}">
        <input type="hidden" name="id" value="${dataMap.id}">
        <div class="row">
            <div class="col-lg-5 col-md-5">
                <div class="form-group">
                    <label for="name_varchar" class="col-lg-3 col-md-3 control-label">名称:<span style="color: red">*</span></label>
                    <div class="col-lg-9 col-md-9">
                        <input type="text" class="form-control" id="name_varchar" name="name_varchar" value="${dataMap.name_varchar}"/>
                    </div>
                </div>
            </div>
            <div class="col-lg-5 col-md-5">
                <div class="form-group">
                    <label for="description_varchar" class="col-lg-3 col-md-3 control-label">描述:</label>
                    <div class="col-lg-9 col-md-9">
                        <input type="text" class="form-control" id="description_varchar" name="description_varchar" value="${dataMap.description_varchar}"/>
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>

<script type="text/javascript">
    //保存角色前先验证表单数据是否合法
    function validateMethod(){
        var name = $("#name_varchar").val();
        if(name == ""){
            alert("名称不能为空!");
            $("#name_varchar").focus();
            return false;
        }
    }

    //编辑角色保存方法(xiaogq)
    function saveEditRole(){
        $('#entity_form').ajaxForm({
            beforeSubmit:validateMethod,
            success:function(balkJson) {
                var flag = balkJson.flag;
                if(!flag){
                    alert("编辑角色失败!");
                    return;
                }
                parent.closeTab(1);
            }
        });
        $("#entity_form").submit();
    }
</script>
</body>
</html>